package org.rugby.online.persistency;

import java.io.Serializable;
import java.util.List;

import org.rugby.online.core.exception.RboException;

/**
 * Interface describing the persistency strategy of the game
 * @author marseille
 */
public interface RboPersistencyStragtegy {
	
	/**
	 * Method to initialize the strategy
	 */
	public void init() throws RboException;
	
	/**
	 * Get the main path for the persistency strategy
	 * @return the main path of this strategy
	 */
	public String getMainPersistencyPath();
	
	/**
	 * Get the persistency folder for a specific class of object
	 * @param clazz the class to search for
	 * @return the given folder
	 */
	public String getPersistencyPathForClass(Class<? extends Serializable> clazz);
	
	/**
	 * Get the list of available persistent objects
	 * @return the list of classes
	 */
	public List<Class<? extends Serializable>> getPersistencyClassList();
	
	/**
	 * Write the object giving its class and identifier
	 * @param clazz the class of the object to write
	 * @param id the identifier of the object
	 * @return true if the object has been successfully written
	 */
	public boolean writeObject(Class<? extends Serializable> clazz, long id, Serializable obj) throws RboException;
	
	/**
	 * Get an object giving its class and identifier
	 * @param clazz the class of the object to get
	 * @param id the identifier of the object
	 * @return the object
	 */
	public Serializable getObject(Class<? extends Serializable> clazz, long id) throws RboException;
	
	/**
	 * Update the object giving its class and identifier
	 * @param clazz the class of the object to update
	 * @param id the identifier of the object
	 * @return true if the object has been successfully updated
	 */
	public boolean updateObject(Class<? extends Serializable> clazz, long id, Serializable obj) throws RboException;
	
	/**
	 * Delete the object giving its class and identifier
	 * @param clazz the class of the object to delete
	 * @param id the identifier of the object
	 * @return true if the object has been successfully deleted
	 */
	public boolean deleteObject(Class<? extends Serializable> clazz, long id) throws RboException;
	
	
	
}
